﻿package plugin.weixin.ui
{
    import cmd.*;
    import com.core.*;
    import com.sh.game.global.*;
    import flash.events.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.weixin.control.*;
    import pluginfw.nio.*;
    import uiresource.weixin.*;
    import view.component.*;
    import view.mornExtends.*;
    import view.uilt.*;

    public class WeiXinUICtrl extends WeixinUI
    {
        private var close:Function;

        public function WeiXinUICtrl(param1:Function)
        {
            this.close = param1;
            return;
        }// end function

        override protected function initializeView() : void
        {
            super.initializeView();
            var _loc_1:* = Control.create(WeiXinControl, this);
            ModelProxy.addObserver("weixin", _loc_1);
            this.init();
            return;
        }// end function

        private function init() : void
        {
            if (Config.gameParams.oper == "360")
            {
                descLabel.text = "关注《360原始传奇》官方微信号，一手掌握最新游戏动态，领取限量微信礼包！不定期参与微信活动，获得丰富游戏大奖！";
                maImg.url = "weixin/wanMa.jpg";
            }
            else
            {
                descLabel.text = "关注《youxi原始传奇》官方微信号，一手掌握最新游戏动态，领取限量微信礼包！不定期参与微信活动，获得丰富游戏大奖！";
                maImg.url = "weixin/youxiMa.jpg";
            }
            this.showItem();
            lingquBtn.addEventListener(MouseEvent.CLICK, this.lingquHandler);
            closeBtn.addEventListener(MouseEvent.CLICK, this.closeHandler);
            return;
        }// end function

        public function updateLiBao(param1:Object) : void
        {
            if (param1.state == 1)
            {
                textinput.text = "";
                ListFly.go(list);
            }
            return;
        }// end function

        private function showItem() : void
        {
            var _loc_1:int = 240702396;
            var _loc_2:* = new Array();
            _loc_2 = ItemUilt.getBoxArr(_loc_1);
            list.array = _loc_2;
            list.renderHandler = new Handler(this.itemRender);
            return;
        }// end function

        private function itemRender(param1:Component, param2:int) : void
        {
            if (param2 < list.length)
            {
                (param1 as FlashItem).data = list.array[param2];
            }
            return;
        }// end function

        private function lingquHandler(event:MouseEvent) : void
        {
            var _loc_2:Output = null;
            if (textinput.text == "")
            {
                ModelProxy.change("movetips", "error", "请输入您的暗号");
            }
            else
            {
                _loc_2 = new Output();
                _loc_2.writeString(textinput.text);
                PluginManager.instance.sendToBufferServer("activity", CMDActivity.AskWeiXinLiBao, _loc_2);
            }
            return;
        }// end function

        private function closeHandler(event:MouseEvent) : void
        {
            this.close();
            return;
        }// end function

    }
}
